/**
 * Created by dio on 2017/2/21 0021.
 */
import React from "react";
import {ScrollView, View} from "react-native";
import chjStyle from "../../../CustomStyle";
import ModuleCommonHeader from "../../module/ModuleCommonHeader";
import Util from "../../Util";
import WarrantyRoadeTest from "./WarrantyRoadeTest";
import SingleSelectionTextItem from "../common/SingleSelectionTextItem";
import NextButton from "../common/NextButton";
import {Actions} from "react-native-router-flux";

export default class WarrantyStartCheck extends React.Component {
    // 构造函数，可执行初始化操作
    constructor(props) {
        super(props);
        // 在ES6，在构造函数里初始化state
        this.state = {};
        if (!Util.selectCar.warrantystartcheck) {
            Util.selectCar.warrantystartcheck = [
                {value: "无", name: "仪表盘有无故障灯指示"},
                {value: "正常", name: "发动机机油泵工作检查"},
                {value: "正常", name: "车辆启动检查（时间少于5秒，或一次启动）"},
                {value: "正常", name: "发动机在冷车状态下怠速运转检查"},
                {value: "正常", name: "发动机在热车状态下怠速运转检查"},
                {value: "正常", name: "怠速运转时发动机检查"},
                {value: "正常", name: "空挡状态下逐渐增加发动机转速，发动机声音过渡检查"},
                {value: "正常", name: "发动机在冷热状态大小水循环工作检查"},
                {value: "正常", name: "启动时踩下制动，观察制动液液面检查"},
                {value: "正常", name: "车辆排气颜色"},
                {value: "正常", name: "发动机内部异响检查"},
                {value: "正常", name: "变速箱内部异响检查"}
            ];
        }
    }

    // 组件被加载时
    componentDidMount() {

    }

    // 组件即将被卸载时
    componentWillUnmount() {
    }

    // 组件被渲染时
    render() {
        return (
            <View style={chjStyle.mainContainer}>
                <ModuleCommonHeader title='启动检查(04)' leftText='返回' clickedRight={this.clickedNew.bind(this)}
                                    rightText='保存'/>
                <ScrollView
                    style={chjStyle.mainList}>
                    {
                        Util.selectCar.warrantyoilcheck.map((item, i) => this.renderItem(item, i))
                    }
                </ScrollView>
                <NextButton onClickedListener={() => this.clickedNew()}/>
            </View>
        );
    }

    renderItem(item, i) {
        switch (i) {
            case 0:
                return (<SingleSelectionTextItem object={item}
                                                 optionArray={[{name: "无"}, {name: "发动机故障灯亮"}, {name: "其它"}]}/>);
            case 5:
            case 6:
                return (<SingleSelectionTextItem object={item}
                                                 optionArray={[{name: "正常"}, {name: "异常"}, {name: "抖动"}, {name: "其它"}]}/>);
            case 9:
                return (<SingleSelectionTextItem object={item}
                                                 optionArray={[{name: "正常"}, {name: "异常"}, {name: "白烟"}, {name: "蓝烟"}, {name: "黑烟"}]}/>);
            default:
                return (
                    <SingleSelectionTextItem object={item} optionArray={[{name: "正常"}, {name: "异常"}, {name: "其它"}]}/>);
        }
    }


    clickedNew() {
        Util.saveData('cars', Util.selectCar);
        Actions.WarrantyRoadeTest(
            {
                name: 'WarrantyRoadeTest',
                component: WarrantyRoadeTest,
            }
        );
    }
}